package edu.serg.mbar.algorithms.functions;

import java.util.Vector;

import org.apache.log4j.Logger;

import edu.serg.mbar.ucon.interfaces.IFunction;

/**
 * This class represents the function which is used to determine whether one item(integer or Decimal) is less than the other
 * 
 * @author Sanaullah
 *
 */

public class LessThan implements IFunction {
	
	static Logger log = Logger.getLogger(LessThan.class);

	@Override
	/**
	 * This Function determines if one number is less than the other ones in the list
	 * 
	 * @param
	 * 		The Vector of Objects representing the numbers which will be compared
	 */
	public Object evaluate(Vector<Object> param) {
		
		log.debug("Received a request to evaluate if the first number is less than the other");
		boolean firstElementIsLesser = false;
		Object result= new Object();
		Double firstNumber = Double.parseDouble((String) param.elementAt(0));
		Double secondNumber = Double.parseDouble((String) param.elementAt(1));
		if (param.size()>2) {
			log.debug("The number of values to be compared are more than two ignoring the other values and considering the first two for comparison");
		}
		log.debug("the value of the firs number is " + firstNumber +" and the Value of the second Number is "+ secondNumber );
			
		if (firstNumber<secondNumber) {
			firstElementIsLesser=true;
			log.debug("First Number is less than the second Number");
		}
		
		result = firstElementIsLesser;
		
		return result;
	}

}
